package util;

public class Point3D {

	private float x, y, z;

	public Point3D(float x, float y, float z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}

	public float getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}

	public float getZ() {
		return z;
	}

	public void setZ(float z) {
		this.z = z;
	}

	public String toString() {
		return "Point3D[" + x + "," + y + "," + z + "]";
	}

	public Point3D minus(Point3D other) {
		return new Point3D(this.x - other.getX(), this.y - other.getY(), this.z
				- other.getZ());
	}

	public Point3D multiplyByScalar(float scalar) {
		return new Point3D(this.x * scalar, this.y * scalar, this.z * scalar);
	}

	public float dotProduct(float otherX, float otherY, float otherZ) {
		return (this.x * otherX) + (this.y * otherY) + (this.z * otherZ);
	}

	public float distanceTo(Point3D other) {
		return (float) Math.sqrt(Math.pow((this.x - other.getX()), 2.0f)
				+ Math.pow((this.y - other.getY()), 2.0f)
				+ Math.pow((this.z - other.getZ()), 2.0f));
	}

}
